import java.util.*;

public class Solution {

    //
    public int minmumNumberOfHost (int n, int[][] startEnd) {

        Arrays.sort(startEnd, (a, b) -> {
            return a[0] <= b[0] ? -1 : 1;
        });

        PriorityQueue<Integer> heap = new PriorityQueue<>();
        heap.offer(startEnd[0][1]);

        for(int i = 1; i < n; i++){
            int a = startEnd[i][0], b = startEnd[i][1];
            if(a >= heap.peek()){
                heap.poll();
                heap.offer(b);
            }else{
                heap.offer(b);
            }
        }
        return heap.size();
    }

    //
}
